package com.wyy.springbootgraphql.resolver;

import com.wyy.springbootgraphql.beans.CommentInput;
import com.wyy.springbootgraphql.beans.Comments;
import graphql.kickstart.tools.GraphQLMutationResolver;
import org.springframework.stereotype.Service;

@Service
public class CommentMutationService implements GraphQLMutationResolver {

    // 新增评论
    public Comments addComment(CommentInput commentInput){
        Comments comments = new Comments(commentInput.getCId(), commentInput.getCText());
        return comments;
    }

    // 删除评论
    public Boolean deleteComment(String id){
        if ("001".equals(id)){
            return true;
        }else
            return false;
    }

    // 修改评论
    public Comments updateComment(CommentInput commentInput){
        if ("001".equals(commentInput.getCId())){
            return new Comments(commentInput.getCId(), commentInput.getCText());
        } else
            return null;
    }

}
